<!-- 今日高级服务人工智能使用次数 -->
<template>
  <event-top :title="'企业智库贡献人员排名'" :chart-data="pieData" />
</template>
<script>
import eventTop from "@/views/home/admin/components/eventTop.vue";
import { connrequest } from "@/api/firstPage";
export default {
  components:{eventTop},
  data() {
    return {
      dataList: [],
      pieData:[],
      listTime:[{'StartTime':'','EndTime':''}],
      total:0
    };
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    this.getData();
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {},
  methods: {
    getTimeList(i){
      // 获取当前日期
      var today = new Date();
      this.listTime[0].StartTime=formatDate(today, 0, true)
      this.listTime[0].EndTime=formatDate(today, 0, false)
      function formatDate(date, daysToAdd, isStart) {
        var newDate = new Date(date);
        newDate.setDate(date.getDate() - daysToAdd);

        var year = newDate.getFullYear();
        var month = String(newDate.getMonth() + 1).padStart(2, '0');
        var day = String(newDate.getDate()).padStart(2, '0');
        var hours = isStart ? '00' : '23';
        var minutes = isStart ? '00' : '59';
        var seconds = isStart ? '00' : '59';
        return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
      }
    },
    async getData() {
      let arr = []
      this.getTimeList()
      const data = {
        Filter: {
          StartTime: this.listTime[0].StartTime,
          EndTime: this.listTime[0].EndTime,
          MsgSubType:'4.0',
          TransDate: '',
          Name:  '',
          Descp:'',
          SumCount: 10
        }
      }
      const res = await connrequest('GetKnowledgeSumGroupByUserID', data);
      if(res.Data){
        res.Data.map(item => {
          arr.push({name: item.UserID, value: item.Count})
          this.total += item.Count
        })
        this.pieData = arr
        this.dataList = res.Data;
      }else{
        const dom = document.getElementById('chart40');
        dom.innerHTML = '<div class="el-table__empty-block"><span class="el-table__empty-text">暂无数据</span></div>';
        dom.removeAttribute('_echarts_instance_');
      }
    }
  }
};
</script>
<style scoped lang='scss'>
.wrap {
  height: calc(50vh - 50px) !important;
  overflow: hidden;

}
.night{
  .el-col-lg-24 {
      background: #303445;
    }
  .wrap{
    ::v-deep .el-table__empty-block{
    background-color: #303445 !important;
  }
  }
}

</style>
